from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene
from core.action import Action

class River2(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.raft_uncrafted = True
        
        # build list of actions
        self.add_action(Out)
        self.add_action(Down)
        self.add_action(Up)
        
    
    def get_description(self):
        if self.raft_uncrafted:
            return 'After hiking what seemed like several miles, you come across the remnants of a raft. It looks like it might be able to be repaired.'  
        else:
            return 'You see the raft you built earlier.'
           
    
    def get_image(self):
        return 'river3.jpg'
    

class River2Handler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return River2

# define actions for this room

class Out(Action):
    def __init__(self):
        Action.__init__(self, "Out")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Walk toward the Lodge"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'river1'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"


class Down(Action):
    def __init__(self):
        Action.__init__(self, "Down")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Continue along the river path"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'river3'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    
class Up(Action):
    def __init__(self):
        Action.__init__(self, "Up")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Ford the river"
    
    def get_destination(self):
        if self.room.raft_uncrafted:
            return 'river2'
        else:
            return 'death'
    
    def do_action(self,game,room,request):
        if self.room.raft_uncrafted:
            set_cutscene("Who do you think you are, Michael Phelps?  There is no chance that you can swim down the river.  There must be another way to cross it.")
        return
   
    def is_enabled(self):
        if self.room.raft_uncrafted == False:
            return True
        else:
            return False
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"